import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 28779
 * Date: 2023-10-28
 * Time: 17:23
 */
public class Demo5 {
    public static void main(String[] args) throws IOException {
        try (InputStream inputStream = new FileInputStream("d:/test.txt")) {
            while (true) {
                byte[] buf = new byte[1024];
                int n = inputStream.read(buf);
                System.out.println("n = " + n);
                if(n == -1) {
                    break;
                }
                for (int i = 0; i < n; i++) {
                    System.out.println("%x " + buf[i]);
                }
                String s = new String(buf, 0, n, "utf-8");
                System.out.println(s);
            }
        }
    }
}
